{extend name="layout" /}
{block name="body"}
<link rel="stylesheet" type="text/css" href="/static/js/bootstrap-datepicker/bootstrap-datepicker3.min.css">
<link rel="stylesheet" type="text/css" href="/static/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" type="text/css" href="/static/js/bootstrap-clockpicker/bootstrap-clockpicker.min.css">
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-body">
                <form name="appsortinfo">
                    <div class="form-group">
                        <label for="adname">广告标题</label>
                        <input type="hidden" class="form-control" id="id" name="id" value="{$appad.id}">
                        <input type="text" class="form-control" id="adname" name="adname" value="{$appad.adname}" placeholder="请输入广告标题">
                    </div>
                    <div class="form-group">
                        <label for="adlink">广告链接</label>
                        <input type="text" class="form-control" id="adlink" name="adlink" value="{$appad.adlink}" placeholder="请输入广告链接">
                    </div>
					<div class="form-group file-group">
					    <label for="adimgurl">广告横幅图</label>
					    <div class="input-group">
					        <input type="text" class="form-control file-value" value="{$appad.adimgurl}" name="adimgurl"
					            value="" placeholder="横幅图" />
					        <input type="file" name="file" accept=".png,.jpg,.jpeg,.bmp,.gif" style="display: none"
					            style="display: none;" />
					        <div class="input-group-btn">
					            <button class="btn btn-default file-browser" type="button">上传横幅图</button>
					        </div>
					    </div>
					</div>
                    <div class="form-group">
						<label for="adtype">显示位置</label>
						<select class="form-control" id="adtype" name="adtype">
							<option value="0" {if $appad['adtype']==0 }selected{/if}>首页显示</option>
							<option value="1" {if $appad['adtype']==1 }selected{/if}>分类页显示</option>
						</select>
					</div>
                    <button type="button" onclick="updatead()" class="btn btn-w-sm btn-primary mb-2">提交</button>
                    <button type="button" class="btn btn-default mb-2"
                        onclick="javascript:history.back(-1);return false;">返
                        回
                    </button>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<!--时间日期选择器-->
<script type="text/javascript" src="/static/js/momentjs/moment.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="/static/js/momentjs/locale/zh-cn.min.js"></script>
<script>	
    function updatead() {
        var l = $('body').lyearloading({
            opacity: 0.2,
            spinnerSize: 'lg',
            spinnerText: '后台处理中，请稍后...',
            textColorClass: 'text-info',
            spinnerColorClass: 'text-info'
        });
        $.ajax({
            type: "POST",
            url: "{:url('app/editad')}",
            data: $("form").serializeArray(),
            dataType: "json",
            success: function (data) {
                setTimeout(function () {
                    l.destroy();
                }, 1e3)
                if (data.code == 1) {
                    notify.success(data.msg);
                } else {
                    notify.error(data.msg);
                }
            },
            error: function () {
                l.destroy();
                notify.error("系统错误");
            }
        })
    }

</script>
{/block}